import store from "./store";
import { increment } from "./store/actions/counter";

export default function App() {
  // 读取数据的方法
  const state = store.getState();

  const handleClick = () => {
    // 更新数据
    // 1. 调用action函数生成action对象
    const action = increment(1);
    // 2. 调用dispatch方法，传入action对象，内部会触发reducer函数
    store.dispatch(action);
  };

  return (
    <>
      <div>App {state.counter}</div>
      <button onClick={handleClick}>+</button>
    </>
  );
}
